<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});
//公众号
Route::any('/wechat/center', ['uses' => 'Wechat\CenterController@index', 'as' => 'wechat.center']);
Route::any('/wechat/setmenu', ['uses' => 'Wechat\CenterController@setMenu', 'as' => 'wechat.setmenu']);
Route::any('/wechat/get_access_token', ['uses' => 'Wechat\CenterController@getAccessToken', 'as' => 'wechat.getAccessToken']);

Route::any('/order/set_print_state', ['uses' => 'OrderAPIController@setPrintState', 'as' => 'orders.setPrintState']);
Route::any('/order/set_fresh_print_state', ['uses' => 'OrderAPIController@setFreshPrintState', 'as' => 'orders.setFreshPrintState']);


//小程序登录接口
Route::post('/xcx/getsession', 'UserCenterController@getSessionKey');
Route::post('/xcx/setlogin', 'UserCenterController@setLogin');
Route::post('/xcx/accesstoken', 'UserCenterController@getAccessToken');
Route::get('/test', 'OrderAPIController@test');
Route::get('/xcx/test', 'UserCenterController@test');

Route::post('/xcx/phone_login', 'UserCenterController@phoneLogin');
//消息接口
Route::any('/xcx/tempmsg/service_to_user', 'UserCenterController@tempmsgServiceToUser');
Route::any('/xcx/tempmsg/user_to_service', 'UserCenterController@tempmsgUserToService');
Route::any('tempmsg_kefu', 'UserCenterController@sendTempMsg');
//发送

//临时图片上传
Route::post('/xcx/upload_temp', 'PicturesController@uploadTemp');

//省市区列表
Route::get('/provinces', 'ProvincesAPIController@index');

//需要分拣的商品
Route::any('orders/goods_timely_sort', 'OrderAPIController@getGoodsTimelySort');

Route::middleware('xcx.checklogin')->group(function () {
    //小程序图片上传
    Route::post('/xcx/upload', 'PicturesController@upload');
    Route::post('/xcx/get-qiniu-token', 'PicturesController@getQiniuToken');

    //用户信息
    Route::get('userinfo','UsersController@userInfo');
    Route::get('cart_number','UsersController@cartNumber');

//    Route::post('set_parentid','UserCenterController@setParentId');
    //发送验证码
    Route::any('sendverifycode','UsersController@sendVerifyCode');
    Route::any('setverifycode','UsersController@setVerifyCode');

    //红包相关
    Route::get('bonus_categories','BonusCategoryAPIController@index');

    Route::any('get_limit_bonus','BonusAPIController@getLimitBonus');
    Route::any('query_limit_bonus','BonusAPIController@queryLimitBonus');
    Route::get('bonuses/{id}','BonusAPIController@show');
    Route::get('bonuses','BonusAPIController@index');

    //购买流程
    Route::any('/add_cart','CartAPIController@add');
    Route::any('/set_cart','CartAPIController@setNumber');

    Route::any('affirm/integral_pay', 'OrderAPIController@integralPay');
    Route::any('affirm/wx_pay', 'OrderAPIController@wxPay');
    Route::any('affirm/check_area', 'OrderAPIController@checkArea');
    Route::any('affirm/wechat_pay', 'OrderAPIController@wechatPay');
    Route::any('orders/pay_config', 'OrderAPIController@getPayConfigByOrder');
    Route::any('orders/wechat_pay_config', 'OrderAPIController@getWechatPayConfigByOrder');
    Route::any('orders/pay_cancel', 'OrderAPIController@payCancel');
    Route::any('orders/return_order', 'OrderAPIController@returnOrder');
    Route::any('orders/return_goods', 'OrderAPIController@returnGoods');


    Route::any('orders/evaluate', 'OrderAPIController@evaluate');

    //配送流程
    Route::any('orders/rob', 'OrderAPIController@rob');
    Route::any('orders/rob_off', 'OrderAPIController@robOff');
    Route::any('orders/pairing_ok', 'OrderAPIController@pairingOk');
    Route::any('orders/verify_ok', 'OrderAPIController@verifyOk');
    Route::any('orders/shipping_start', 'OrderAPIController@shippingStart');
    Route::any('orders/shipping_end', 'OrderAPIController@shippingEnd');
    Route::any('orders/cancel', 'OrderAPIController@cancel');
    Route::any('orders/set_order_shipping_area', 'OrderAPIController@setShippingArea');
    Route::any('distribution/statistics', 'StatisticsAPIController@distributionStatistics');

    //商品数量增加
    Route::any('goods/add_number', 'GoodsAPIController@addNumber');

    Route::resource('carts', 'CartAPIController');
    Route::resource('orders', 'OrderAPIController');
    Route::resource('addresses', 'AddressAPIController');
    Route::resource('integral_logs', 'IntegralLogAPIController');
});
Route::any('configs_by_group/{group}', 'ConfigAPIController@getConfigsByGroup');
Route::post('setting/index_layout', 'ConfigAPIController@setIndexLayout');
Route::any('setting/index_layout_test', 'ConfigAPIController@setIndexLayoutTest');


Route::any('pipe/post','UtilController@pipePost');
Route::any('js/config','Wechat\CenterController@jsConfig');

//付款 异步 通知
Route::any('pay/notification','OrderAPIController@notification');
Route::any('pay/notification/wechat','OrderAPIController@notificationByWechat');

Route::any('configs/hot_keyword','ConfigAPIController@getHotKeyword');
Route::any('configs/shipping_area','ConfigAPIController@getShippingArea');
Route::any('configs/group/{group}','ConfigAPIController@getByGroup');

Route::resource('categories', 'CategoryAPIController');
Route::resource('configs', 'ConfigAPIController');

Route::resource('slideshows', 'SlideshowAPIController');

Route::resource('layouts', 'LayoutAPIController');

Route::resource('goods', 'GoodsAPIController');
Route::get('goods_attribute_type', 'GoodsAttributeTypeAPIController@index');

//评价列表
Route::get('evaluates', 'EvaluateAPIController@index');
//Route::get('evaluates/{id}', 'GoodsEvaluateAPIController@show');

//导航条
Route::get('navigates', 'NavigateAPIController@index');

//文章
Route::get('articles', 'ArticlesAPIController@index');
Route::get('articles/point/{id}', 'ArticlesAPIController@point');
Route::get('articles/{id}', 'ArticlesAPIController@show');
//Route::resource('goods_evaluates', 'EvaluateAPIController');

//Route::resource('goods_attributes', 'GoodsAttributeAPIController');
//
//Route::resource('goods_contents', 'GoodsContentAPIController');
//
//Route::resource('goods_attributes', 'GoodsAttributeAPIController');
//
//Route::resource('goods_slideshows', 'GoodsSlideshowAPIController');
//
//Route::resource('bonuses', 'BonusAPIController');

//Route::resource('carts', 'CartAPIController');
//
//
//Route::resource('pay_records', 'PayRecordAPIController');
//
//
//Route::resource('return_logs', 'ReturnLogAPIController');
//
//Route::resource('statistics', 'StatisticsAPIController');
//
//Route::resource('roles', 'RoleAPIController');
//
//Route::resource('goods_number_logs', 'GoodsNumberLogAPIController');


Route::resource('category_statistics', 'CategoryStatisticsAPIController');

Route::resource('distribution_statistics', 'DistributionStatisticsAPIController');

Route::resource('freights', 'FreightAPIController');

Route::resource('freight_areas', 'FreightAreaAPIController');